package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckGroupMapper {

    //查询所有
    @Select("select * from t_checkgroup")
    List<CheckGroup> selectall();

    //根据检查组id查询检查项id
    @Delete("delete from t_group_item where checkitem_id = #{id}")
    void deleteAssociation(Integer id);

    //根据检查项id查询检查组id
    @Select("select checkgroup_id from t_group_item where checkitem_id=#{id}")
    List<Long> findCheckGroupIdByCheckItemId(Integer id);

    //添加检查组
    void insert(CheckGroup group);
    
    //删除检查组
    @Delete("delete from t_checkgroup where id = #{id}")
    void delete(Integer id);

    //根据检查组id查询检查组
    @Select("select * from t_checkgroup where id=#{id}")
    CheckGroup findById(Integer id);

    //编辑检查组
    void edit(CheckGroup group,Integer[] checkitemIds);

    //分页查询
    Page<CheckGroup> selectByCondition(QueryPageBean queryPageBean);

    //根据套餐id查询检查组
    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id}")
    List<Integer> findCheckGroupIdBysetmealId(Integer setmealId);


    void insertCheckitemIds(Integer gruopId, Integer checkitemId);

    void updateCheckitemIds(Integer groupId, Integer checkitemId);

    List<CheckGroup> findCheckGroupById(Integer id);

}
